using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Dimok.Data.Database;
using Dimok.User;

namespace Dimok.GLRules{
	public class GLRules : System.Web.UI.Page{
		protected HtmlGenericControl ttlTitle;
		protected Literal ltrTree;
		protected Literal ltrInfo;
		protected HtmlSelect selBanks;
		protected HtmlSelect selProgs;
		public UserObject uox = new UserObject();
		
		private void Page_Load(object sender, System.EventArgs e){
			int bankID = UserObject.GetQueryParamInt("BankID");
			int programID = UserObject.GetQueryParamInt("ProgramID");
			string applID = uox.hasApplID ? uox.applID.ToString() : "";
			SQLHelperEx.SELECT(selBanks,uox.db_GL,"SELECT ID,Name FROM t_Bank ORDER BY Name","Name","ID");
			int realTime = Convert.ToInt32(SQLHelperEx.ExecuteScalarEx(uox.db_GL,"SELECT dbo.Config_RealTime()"));
			int treeDebug = Convert.ToInt32(SQLHelperEx.ExecuteScalarEx(uox.db_GL,"SELECT dbo.Config_TreeDebug()"));
			DataTable dtInfo = SQLHelperEx.ExecuteDatasetEx(uox.db_GL,"SELECT ID AS ProgramID,BankID,'"+applID+"' AS ApplID,"+realTime+" AS RealTime,"+treeDebug+" AS TreeDebug FROM t_LoanProgram WHERE ID=@ID",programID).Tables[0];
			if( dtInfo.Rows.Count == 0 )dtInfo.Rows.Add(new object[]{bankID,programID,applID,realTime,treeDebug});
			SQLHelperEx.SELECT(selProgs,uox.db_GL,"SELECT ID,Name FROM t_LoanProgram WHERE BankID=@BankID ORDER BY Position","Name","ID",dtInfo.Rows[0]["BankID"]);
			ltrInfo.Text = dtInfo.DataSet.GetXml();
			//ltrTree.Text = uox.GetGLRulesXML(Request["TierID"]);
	}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);
		}
		#endregion
	}
}
